package product;

import java.util.Date;
import java.util.UUID;

public class SaleRecord {
    private String ticketId; // 电子票号（UUID）
    private Show show; // 关联场次
    private Seat seat; // 关联座位
    private double price; // 票价
    private Date saleTime; // 售票时间
    private boolean isRefunded; // 是否退票
    private Date refundTime; // 退票时间
    private double refundAmount; // 退票金额

    public SaleRecord(Show show, Seat seat, double price) {
        this.ticketId = UUID.randomUUID().toString();
        this.show = show;
        this.seat = seat;
        this.price = price;
        this.saleTime = new Date();
        this.isRefunded = false;
    }

    // Getter和Setter
    public String getTicketId() { return ticketId; }
    public Show getShow() { return show; }
    public Seat getSeat() { return seat; }
    public double getPrice() { return price; }
    public boolean isRefunded() { return isRefunded; }
    public void setRefunded(boolean refunded) { isRefunded = refunded; }
    public Date getRefundTime() { return refundTime; }
    public void setRefundTime(Date refundTime) { this.refundTime = refundTime; }
    public double getRefundAmount() { return refundAmount; }
    public void setRefundAmount(double refundAmount) { this.refundAmount = refundAmount; }

    // 显示票信息
    public void displayTicket() {
        System.out.printf("电子票号：%s\n片名：%s\n场次：%s %s\n座位：%d排%d号\n票价：%.2f元\n",
                ticketId, show.getMovie().getName(), show.getHall(), show.getTime(),
                seat.getRow(), seat.getCol(), price);
    }

    public Date getSaleTime() {
        return saleTime;
    }
}